#!/usr/bin/perl
# diskswap.cgi in diskman

require './diskman-lib.pl';

&ReadParse();
$diskindex = $in{'disk'};
if ($diskindex =~ /^p(\d*)/) {
    $nn = $1;
}
@disks = new_get_diskinfo();
@ctrl = &get_ctrl_num(); 
if ($diskindex =~ /p(\d*)/) {
    $dnum = $1;
}
$uid = $disks[$dnum]->{'raidid'};
#`echo $ctrl[0] >>/root/niu`;
if( $uid =~ /^u\d*/ ) {

    system("/sbin/tw_cli/tw_cli /$ctrl[0]/$uid del noscan quiet");
}
else{
    system("/sbin/tw_cli/tw_cli /$ctrl[0] add type=spare disk=$nn name=spare");

}

&redirect("index.cgi");


